#pragma once

#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <unordered_map>
#include <memory>
#include <queue>
#include <nlohmann/json.hpp>
#include <unordered_map>
#include "commonFunction.h"
#include "ShareQueue.h"
#include "Thread.h"

class MessageHandler :public Thread{
public:
    MessageHandler();
    void add_message_to_queue(std::shared_ptr<webDataInfo> webData);
    std::unique_ptr<ShareQueue<std::shared_ptr<webDataInfo>>> inputWebQueue;

    void msgProcess(const nlohmann::json& msgJson);

    //void run();
    virtual void process() override;

    virtual void beforeHandle() override {

    };
    /*virtual void setup(const std::string& message) override {

    }*/

private:
    void process_message(const std::string& message);
    
    std::shared_ptr<boost::asio::io_context> httpIoc;
    std::mutex mutex, mapMutex;
    std::condition_variable cond_variable, mapCond_variable;
    bool canInput = true;
    
};

